# pundits parrot routine
library(parrot)

source("pundits_functions.R")

set.seed(1111)
files <- list.files(path = "../output/parrots/",
                    pattern = "*.RData")

# plot keywords for each concept
# figure 2 is this for immigration
# all concepts are shown in figures E1-E22
for(l in files){
  load(paste0("../output/parrots/",l))
    
  cname <- gsub("_parrot.RData", "", l)
    
  #ggsave(p, file = paste0("../figures/wordscores/",cname, "_dims1and2.png"), width = 10, height = 8)
  ragg::agg_tiff(paste0("../figures/wordscores/",cname, "_dims1and2.tiff"), 
                 width=12, height=8, units = "in", 
                 res = 300)
    print(plot_keywords_custom(thel,
                            q_cutoff = .95,
                            dims_cutoff = .2,
                            subjname = cname)+
    theme_jg())
    dev.off()
    
}
